/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.bluesbruce.so.radio;

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.DoubleByReference;

/**
 * 通过JNA调用SO文件
 *
 * <pre>
 * char* argv[]可以用String[]表示。
 * char* argv用byte[]，ByteBuffer，String表示。在表示回参时，使用byte[]和ByteBuffer表示。
 * </pre>
 *
 * @author BBF
 * @see <a href="https://github.com/java-native-access/jna/blob/master/www/Mappings.md">参数映射</a>
 */
public interface RadioSo extends Library {

  RadioSo INSTANCE = Native.load(GetLibraryPathHelper.GetLibPath(), RadioSo.class);

  void zxdqmx_(DoubleByReference IYR, DoubleByReference IDAY, Pointer IHR, Pointer IMIN,
      Pointer SEC, Pointer XLAT, Pointer XLON, Pointer XHT, Pointer F10, Pointer F10B,
      Pointer XKP, Pointer TEMP, Pointer RHO, Pointer N2, Pointer O2, float[] W);
  /* 这里使用了DoubleByReference 和 Pointer，从实际效果上是等价的，DoubleByReference是封装了Pointer */

  /**
   * static interface method need jdk1.8. here we use inner class to avoid this problem.
   */
  class GetLibraryPathHelper {

    // can replaced by absolute path
    public static String GetLibPath() {
      return "/hty_web/ZXDQMX.so";
    }
  }
}
